home *** CD-ROM | disk | FTP | other *** search
/ PC World Interactive 1 / PC World Interactive 1 - Nisan 1997.iso / nostalji / bbs / music / sbbook.arj / SBBOOK / SOURCE / TP / PLAYCMF.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1993-11-23  |  3.3 KB  |  118 lines

  1. (*********************************************************************
  2. *
  3. *  PROGRAM NAME: PLAYCMF.PAS
  4. *
  5. *  COMPILER: Borland Turbo Pascal ver. 4 or later
  6. *
  7. *  DESCRIPTION: Plays a .CMF FM file from the disk using the FMDRV
  8. *               driver (accessed from SBSIM).  To run the program,
  9. *               type the following at the command line:
  10. *
  11. *               PLAYCMF FILENAME
  12. *
  13. *               Where FILENAME is the drive/path/filename of the .CMF
  14. *               file to play.
  15. *
  16. *  NOTE: SBSIM driver must be loaded before running this program.
  17. *
  18. *********************************************************************)
  19.  
  20. program playcmf;
  21. uses dos,crt;
  22.  
  23. const FM_DRIVER = $01;
  24.  
  25.  
  26. {$I drvrfunc.pas}
  27.  
  28. var Command:char;
  29.     UserQuit:boolean;
  30.     FileHandle:integer;
  31.     RetValue:simerr;
  32.     FileName:string;
  33.  
  34. (********************************************************************)
  35.  
  36. begin (* main *)
  37.  
  38. if paramcount <> 1  (* no. of parameters entered on command line *)
  39. then begin
  40.      writeln('Command line must contain EXACTLY ONE filename parameter!');
  41.      halt;   (* Terminate program *)
  42.      end;
  43.  
  44. (*--- SEE IF SBSIM DRIVER HAS LOADED --*)
  45. SIMint := FindDvr('SBSIM', $0103);  (* Get SBSIM's interrupt no. *)
  46. if SIMint = 0
  47. then begin
  48.      writeln('SBSIM driver not loaded!');
  49.      halt;   (* Terminate program *)
  50.      end;
  51.  
  52. (*--- SEE IF FM DRIVER HAS LOADED --------*)
  53. if (GetDrvrs and FM_DRIVER) <> FM_DRIVER
  54. then begin
  55.      writeln('FMDRV not loaded!');
  56.      halt;
  57.      end;
  58.  
  59. (*--- LOAD THE FILE -------------------*)
  60. FileHandle := DosOpen(paramstr(1), ReadAccess);
  61. if (FileHandle = -1)
  62. then begin
  63.      writeln('FILE: ',paramstr(1), ' not successfully opened!');
  64.      halt;    (* Terminate program *)
  65.      end;
  66.  
  67. DosClose(FileHandle);
  68.  
  69. FileName := paramstr(1);  (* copy to string with more space before modifying *)
  70.  
  71. (*--- StartSnd() LOADS THE FILE AND INITIALIZES THE DRIVER ---*)
  72. RetValue := StartSnd(FM, AsciiZ(FileName), false, 0);
  73. if RetValue <> SIMerr_NoErr
  74. then begin
  75.      writeln('ERROR CALLING SBSIM: ', errorMsg[RetValue]);
  76.      halt;  (* Terminate program *)
  77.      end;
  78.  
  79. (*--- PlaySnd() BEGINS PLAYING THE FILE -------------*)
  80. RetValue := PlaySnd(FM);
  81. if RetValue <> SIMerr_NoErr
  82. then begin
  83.      writeln('ERROR CALLING SBSIM: ', errorMsg[RetValue]);
  84.      halt;  (* Terminate program *)
  85.      end;
  86.  
  87. clrscr;  (* Clear screen *)
  88. writeln(#10#10#10#10#10'     SELECT ONE OF THE FOLLOWING OR WAIT UNTIL DONE:');
  89. writeln('                   (P)ause');
  90. writeln('                   (R)esume');
  91. writeln('                   (Q)uit');
  92.  
  93. UserQuit := false;
  94.  
  95. (*--- PROCESS USER INTERACTION OR WAIT FOR SOUND TO STOP -----------*)
  96. repeat
  97.      if (keypressed)  (* Was a key pressed? *)
  98.      then begin
  99.           Command := upcase(readkey);  (* Get char that's in buffer *)
  100.           if Command = 'P'
  101.           then PauseSnd(FM)
  102.           else if Command = 'R'
  103.           then ResumeSnd(FM)
  104.           else if Command = 'Q'
  105.           then UserQuit := true;
  106.           end;
  107. (* Exit do-while loop if file is done playing or user typed 'Q' *)
  108. until (UserQuit = true) or (GetSndStat(FM) = 0);
  109.  
  110.  
  111. (*--- IF SOUND IS STILL PLAYING AND USER HIT 'Q', STOP THE SOUND ---*)
  112. if (GetSndStat(FM) <> 0) and (UserQuit = true)
  113. then StopSnd(FM);
  114.  
  115. end.
  116.  
  117.  
  118.